import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/view/Index'
import Test from '@/view/Test'
import Lunbo from '@/view/lunbo'
import singleHome from '@/view/singleHome'
import rentSearch from '@/view/rentSearch'
import fabuHouse from '@/view/fabuHouse'
import userMessage from '@/view/userMessage'
import rebackpwd1 from '@/view/rebackpwd1'
import rebackpwd2 from '@/view/rebackpwd2'
import message from '@/view/message'
import Iwant from '@/view/Iwant'
import tucao from '@/view/tucao'
import jisuanqi from '@/view/jisuanqi'
import kefu from '@/view/kefu'
import error from '@/view/error'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/', name: '首页', component: Index,
      meta: { title: '泊寓|温暖停泊处' }
    },
    {
      path: '/test', name: '测试页面', component: Test,
      meta: { title: '测试页面' }
    },
    { path: '/lunbo', name: '测试轮播', component: Lunbo, meta: { title: '测试页面' } },
    { path: '/singleHome/:id', name: '单个房子', component: singleHome, meta: { title: '泊寓|房屋信息' } },
    { path: '/rentSearch', name: '查找房子', component: rentSearch, meta: { title: '泊寓|青岛在线租房' } },
    { path: '/fabuHouse', name: '发布房源', component: fabuHouse, meta: { title: '泊寓|发布房源' } },
    { path: '/userMessage', name: '用户个人中心', component: userMessage, meta: { title: '泊寓|个人中心' } },
    { path: '/rebackpwd1', name: '找回密码-邮箱验证', component: rebackpwd1, meta: { title: '泊寓|找回密码-邮箱验证' } },
    { path: '/rebackpwd2', name: '找回密码-新密码', component: rebackpwd2, meta: { title: '泊寓|找回密码-新密码' } },
    { path: '/message', name: '消息通知', component: message, meta: { title: '泊寓|消息通知' } },
    { path: '/Iwant', name: '我想要', component: Iwant, meta: { title: '泊寓|我想要' } },
    { path: '/tucao', name: '吐槽一下', component: tucao, meta: { title: '泊寓|吐槽一下' } },
    { path: '/jisuanqi', name: '房贷计算机', component: jisuanqi, meta: { title: '泊寓|房贷计算器' } },
    { path: '/kefu', name: '在线客服', component: kefu, meta: { title: '泊寓|在线客服' } },
    { path: '/error', name: '错误页面', component: error, meta: { title: '泊寓|发生错误' } },
    { path: '*', redirect: '/error'},
  ]
})

// router.beforeEach((to, from, next) => {

//   document.title = to.matched[0].meta.title;
//   next()
// })

export default router